<?php
class CategoryAction extends  CommonAction{
	public function categoryMg(){
		import('Class.Category',APP_PATH);
		$cate=M('category')->order('sort asc')->select();
		$this->cate=Category::unlimitedForLevel($cate);
		$this->display();
	}
	public function categoryAdd(){
		$this->pid=I('pid',0,'intval');
		$this->display();
	}
	public function cateAdd(){
		if (M('category')->add($_POST)) {
			$this->success('添加成功',U(GROUP_NAME.'/Category/categoryMg'));
		}else{
			$this->error('添加失败');
		}
	}
	
	public function sortCate(){
		$cate=M('category');
		foreach ($_POST as $key => $value) {
			 $cate->where(array('id'=>$key))->setField('sort', $value);
		}
		$this->redirect(GROUP_NAME.'/Category/categoryMg');
	}
}
?>